﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
using Common;
public partial class admin_UserControl_CheckList : System.Web.UI.UserControl
{
    Log_Check bll_Log_Check = new Log_Check();
    private int _ObjectId;

    public int ObjectId
    {
        get { return _ObjectId; }
        set { _ObjectId = value; }
    }
    private PublicEnum.ObjectType_Check _ObjectType;

    public PublicEnum.ObjectType_Check ObjectType
    {
        get { return _ObjectType; }
        set { _ObjectType = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            UIInit();
        }
    }

    public void NeedRefresh()
    {
        UIInit();
    }

    private void UIInit()
    {
        Bind_GridView();
    }

    private void Bind_GridView()
    {
        DataTable dt = bll_Log_Check.GetList(GetWhere()).Tables[0];
        dt.Columns.Add("ResultName");
        Helper_CreateHTMLPiece helper_CreateHTMLPiece = new Helper_CreateHTMLPiece();
        foreach (DataRow dr in dt.Rows)
        {
            if (!Convert.ToBoolean(dr["IsDispose"]))
            {
                dr["ResultName"] = helper_CreateHTMLPiece.ColorFont("待处理","blue");
            }
            else
            {
                dr["ResultName"] = helper_CreateHTMLPiece.ColorFont_Check(Convert.ToBoolean(dr["Result"]));
            }
            
        }
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

    private string GetWhere()
    {
        string where = "ObjectType = " + Convert.ToInt32(_ObjectType).ToString();
        where += " and ObjectId = " + _ObjectId.ToString();
        return where;
    }
}